{% block sw_settings_search_search_index %}
<mt-card
    position-identifier="sw-settings-search-search-index"
    :title="$tc('sw-settings-search.generalTab.labelSearchIndex')"
    :is-loading="isLoading"
>

    {% block sw_settings_search_search_index_description %}
    <mt-banner
        v-if="isRebuildInProgress"
        class="sw-settings-search__search-index-warning-text"
        variant="attention"
    >

        {% block sw_settings_search_search_index_warning_top %}
        <p class="sw-settings-search__search-index-warning-top">
            {{ $tc('sw-settings-search.generalTab.textWarningOpenTab') }}
        </p>
        {% endblock %}

        {% block sw_settings_search_search_index_warning_bottom %}
        <p>{{ $tc('sw-settings-search.generalTab.textRebuildSearchIndexDescription') }}</p>
        {% endblock %}

    </mt-banner>
    {% endblock %}

    {% block sw_settings_search_search_index_rebuild_button %}
    <sw-button-process
        variant="primary"
        ghost
        class="sw-settings-search__search-index-rebuild-button"
        :is-loading="isRebuildInProgress"
        :disabled="isRebuildInProgress || !acl.can('product_search_config.editor')"
        :process-success="isRebuildSuccess"
        @update:process-success="buildFinish"
        @click="rebuildSearchIndex"
    >
        {{ $tc('sw-settings-search.generalTab.buttonRebuildSearchIndex') }}
    </sw-button-process>

    {% block sw_settings_search_search_index_lastest_build %}
    <span class="sw-settings-search__search-index-latest-build">
        <template v-if="latestIndex">
            {{ $tc('sw-settings-search.generalTab.textLastedBuild') }} <sw-time-ago :date="latestIndex.firstDate" /> &dash; <sw-time-ago :date="latestIndex.lastDate" />
        </template>
        <template v-else>
            {{ $tc('sw-settings-search.generalTab.textSearchNotIndexedYet') }}
        </template>
    </span>
    {% endblock %}
    {% endblock %}

    {% block sw_settings_search_search_index_rebuild_progress %}
    <div
        v-if="progressBarValue"
        class="sw-settings-search__search-index-rebuilding-progress"
    >

        {% block sw_settings_search_search_index_rebuild_progress_text %}
        <span class="sw-settings-search__search-index-rebuilding-text">
            {{ $tc('sw-settings-search.generalTab.textRebuildingSearchIndex') }}
        </span>
        {% endblock %}

        {% block sw_settings_search_search_index_rebuild_progress_bar %}
        <mt-progress-bar
            :model-value="progressBarValue"
            :max-value="100"
        >
            {{ $tc('sw-settings-search.generalTab.textRebuildingSearchIndex') }}
        </mt-progress-bar>
        {% endblock %}
    </div>
    {% endblock %}

</mt-card>
{% endblock %}
